$def with (form)

<form name="main" method="post">
$if not form.valid:<p class="error">Form is not valid:</p>
$:form.render() <input type="submit" />    </form>